package com.banyuan.excrise;

import com.banyuan.IOUtilis;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/* 输入一行字符串，然后传换成繁体字
 *
 * */
public class TranStr {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入简体字：");
        String str = scanner.nextLine();

        InputStream is = null;
        InputStreamReader isr = null;
        BufferedReader br = null;
        Map<String,String> map = new HashMap<>();

        try {
            is = new FileInputStream("/Users/edy/Desktop/file/jf_map_utf8.txt");
            isr = new InputStreamReader(is);
            br = new BufferedReader(isr);
            String len;
            while ((len = br.readLine()) != null) {
                String[] split = len.split(":");
                map.put(split[0],split[1]);
            }
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < str.length(); i++) {
                char c = str.charAt(i);
                String s = map.get(String.valueOf(c));
                if (s == null) {
                    sb.append(c);
                }else {
                    sb.append(s);
                }
            }
            System.out.println(sb.toString());
        }
        catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            IOUtilis.closeQuiety(br);
            IOUtilis.closeQuiety(isr);
            IOUtilis.closeQuiety(is);
        }


    }

}
